<?php if($this->errMsg) :?>
	<?php $this->showError($this->errMsg)?>
<?php endif; ?>
<?php if($this->msg) :?>		
	<?php $this->showMessage($this->msg)?>	
<?php endif;?>
<form name='form' id='form' action="" method="POST">
	<div class="title_ad"><label><a href="">Edit Group</a></label>
	<a style="text-align:right;float:right;margin-right:20px;" href=""><img src="<?php echo $this->baseUrl()?>/application/templates/admin/images/plus_32.png" /></a></div>
	<div class="mydiv">
	<table  class="tb_box">
	
		<tr>
			<td width="130">
				<label>Tên Group</label>
			</td>			
			<td>						
				<input type="text" name='name' value="<?php echo $this->obj->name;?>" class='name' />
				<p class='error'></p>
			</td>	
				
		</tr>				
	</table>
	<div style="text-align: center;" id='listPrivileges'>
	<table style="width: 50%; padding-left: 10px;" class='demo'>
		<tr>
			<td><input disabled="disabled"<?php echo $this->check($this->arrcontrollername,"user");?> type="checkbox" id="user" value="user" size="2">Người Dùng</td>
			<td id="arrayuser" align="center" width="25px"><a class='btn-12 arrowoff' href="javascript:getPrivileges('user')"></a></td>
		</tr>
		<tr style="float: right;width: 95%;padding-left: 30px" id='truser'></tr>
		<tr>
			<td><input disabled="disabled" <?php echo $this->check($this->arrcontrollername,"group");?> type="checkbox" id="group" value="group">Nhóm quyền<br></td>
			<td id="arraygroup" align="center"><a class='btn-12 arrowoff' href="javascript:getPrivileges('group')"></a></td>
		</tr>
		<tr style="float: right;width: 95%;padding-left: 30px" id='trgroup'></tr>
		<tr>
			<td><input disabled="disabled" <?php echo $this->check($this->arrcontrollername,"news");?> type="checkbox" id="news" value="news">Tin<br></td>
			<td id="arraynews" align="center"><a class='btn-12 arrowoff' href="javascript:getPrivileges('news')"></a></td>
		</tr>
		<tr style="float: right;width: 95%;padding-left: 30px" id='trnews'></tr>
		<tr>
			<td><input disabled="disabled" <?php echo $this->check($this->arrcontrollername,"comment");?> type="checkbox" id="comment" value="comment">Bình luận<br></td>
			<td id="arraycomment" align="center"><a class='btn-12 arrowoff' href="javascript:getPrivileges('comment')"></a></td>
		</tr>
		<tr style="float: right;width: 95%;padding-left: 30px" id='trcomment'></tr>
		<tr>
			<td><input disabled="disabled" <?php echo $this->check($this->arrcontrollername,"forum");?> type="checkbox" id="forum" value="forum">Chuyên Mục<br></td>
			<td id="arrayforum" align="center"><a class='btn-12 arrowoff' href="javascript:getPrivileges('forum')"></a></td>
		</tr>
		<tr style="float: right;width: 95%;padding-left: 30px" id='trforum'></tr>
		<tr>
			<td><input disabled="disabled" <?php echo $this->check($this->arrcontrollername,"typenews");?> type="checkbox" id="typenews" value="typenews">Loại Tin<br></td>
			<td id="arraytypenews" align="center"><a class='btn-12 arrowoff' href="javascript:getPrivileges('typenews')"></a></td>
		</tr>
		<tr style="float: right;width: 95%;padding-left: 30px" id='trtypenews'></tr>
		<tr>
			<td><input disabled="disabled" <?php echo $this->check($this->arrGP,"quest");?> type="checkbox" id="quest" value="quest">Khảo sát<br></td>
			<td id="arrayquest" align="center"><a class='btn-12 arrowoff' href="javascript:getPrivileges('quest')"></a></td>
		</tr>
		<tr style="float: right;width: 95%;padding-left: 30px" id='trquest'></tr>
		<tr>
			<td colspan="2"><input <?php echo $this->check($this->arrGP,24);?> type="checkbox" name="privileges[]" value="24">Lược sử
		</tr>
	</table>
	</div>
	<div class='div_button' >	
		<input type="submit" value="Sửa" class='button1'/>
		<input type="reset" value="Làm lại" class='button2' />
	</div>	
	</div>
<div id='user' style="display:none;">
	<table style="width: 90%;">
		<tr>
			<td><input <?php echo $this->check($this->arrGP,1);?> id="userc[]" onclick="javascript:check('user')" type="checkbox" name="privileges[]" value="1">Danh Sách</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,2);?> id="userc[]" onclick="javascript:check('user')" type="checkbox" name="privileges[]" value="2">Sửa<br></td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,3);?> id="userc[]" onclick="javascript:check('user')" type="checkbox" name="privileges[]" value="3">Thay đổi trạng thái<br></td>
		</tr>
	</table>
</div>
<div id='group' class='group' style="display:none;">
	<table>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,4);?> id="groupc[]" onclick="javascript:check('group')"  type="checkbox" name="privileges[]" value="4">Danh Sách</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,5);?> id="groupc[]" onclick="javascript:check('group')" type="checkbox" name="privileges[]" value="5">Sửa<br></td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,6);?> id="groupc[]" onclick="javascript:check('group')" type="checkbox" name="privileges[]" value="6">Thêm mới<br></td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,25);?> id="groupc[]" onclick="javascript:check('group')" type="checkbox" name="privileges[]" value="25">xóa<br></td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,7);?> id="groupc[]" onclick="javascript:check('group')" type="checkbox" name="privileges[]" value="7">Cập nhật trạng thái<br></td>
		</tr>
	</table>
</div>
<div id='forum' style="display:none;">
	<table style="width: 90%;">
		<tr>
			<td><input <?php echo $this->check($this->arrGP,8);?> id="forumc[]" onclick="javascript:check('forum')" type="checkbox" name="privileges[]" value="8">Danh Sách</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,9);?> id="forumc[]" onclick="javascript:check('forum')" type="checkbox" name="privileges[]" value="9">Sửa</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,10);?> id="forumc[]" onclick="javascript:check('forum')" type="checkbox" name="privileges[]" value="10">Thêm mới</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,11);?> id="forumc[]" onclick="javascript:check('forum')" type="checkbox" name="privileges[]" value="11">Sắp xếp</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,12);?> id="forumc[]" onclick="javascript:check('forum')" type="checkbox" name="privileges[]" value="12">xóa</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,13);?> id="forumc[]" onclick="javascript:check('forum')" type="checkbox" name="privileges[]" value="13">Cập nhật trạng thái</td>
		</tr>
	</table>
</div>
<div id='comment' style="display:none;">
	<table style="width: 90%;">
		<tr>
			<td><input <?php echo $this->check($this->arrGP,26);?> id="commentc[]" onclick="javascript:check('comment')" type="checkbox" name="privileges[]" value="26">Danh sách</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,28);?> id="commentc[]" onclick="javascript:check('comment')" type="checkbox" name="privileges[]" value="28">Xóa</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,27);?> id="commentc[]" onclick="javascript:check('comment')" type="checkbox" name="privileges[]" value="27">Cập nhật trạng thái</td>
		</tr>
	</table>
</div>
<div id='typenews' style="display:none;">
	<table style="width: 90%;">
		<tr>
			<td><input <?php echo $this->check($this->arrGP,15);?> id="typenewsc[]" onclick="javascript:check('typenews')" type="checkbox" name="privileges[]" value="15">Sửa</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,14);?> id="typenewsc[]" onclick="javascript:check('typenews')" type="checkbox" name="privileges[]" value="14">Thêm mới</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,16);?> id="typenewsc[]" onclick="javascript:check('typenews')" type="checkbox" name="privileges[]" value="16">xóa</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,17);?> id="typenewsc[]" onclick="javascript:check('typenews')" type="checkbox" name="privileges[]" value="17">Cập nhật trạng thái</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,19);?> id="typenewsc[]" onclick="javascript:check('typenews')" type="checkbox" name="privileges[]" value="19">Sắp xếp</td>
		</tr>
	</table>
</div>
<div id='quest' style="display:none;">
	<table style="width: 90%;">
		<tr>
			<td><input <?php echo $this->check($this->arrGP,20);?> id="questc[]" onclick="javascript:check('quest')" type="checkbox" name="privileges[]" value="20">Danh Sách</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,21);?> id="questc[]" onclick="javascript:check('quest')" type="checkbox" name="privileges[]" value="21">Sửa</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,22);?> id="questc[]" onclick="javascript:check('quest')" type="checkbox" name="privileges[]" value="22">Thêm mới</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,23);?> id="questc[]" onclick="javascript:check('quest')" type="checkbox" name="privileges[]" value="23">Xóa</td>
		</tr>
	</table>
</div>
<div id='news' style="display:none;">
	<table style="width: 90%;">
		<tr>
			<td><input <?php echo $this->check($this->arrGP,300);?> id="newsc[]" onclick="javascript:check('news')" type="checkbox" name="privileges[]" value="index">Danh Sách</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,100);?> id="newsc[]" onclick="javascript:check('news')" type="checkbox" name="privileges[]" value="edit">Sửa</td>
		</tr>
		<tr>
			<td><input <?php echo $this->check($this->arrGP,1000);?> id="newsc[]" onclick="javascript:check('news')" type="checkbox" name="newsP[]" value="new">Thêm mới</td>
		</tr>
	</table>
</div>
</form>
<script>
$(document).ready(function(){
	$('.button1').click(function(){
		$('.error').html('');
		if($('.name').val()=="")
		{
			$(".error").append("<label class='error' >Tên Group không được để trống</label>");
			$('.name').focus();
			return false;
		}	
		else if($('.name').val().length < 5 )
		{
			$(".error").append("<label class='error' >Tên Group phải lớn hơn 4 kí tự</label>");
			$('.name').focus();
			return false;
		}
		else return true;	
	});
});

function getPrivileges(key)
{
	$('#array'+key).html('<a class="btn-12 arrowon" href="javascript:removePrivileges(\''+key+'\')"></a>');
	var privileges = $('div#'+key).html();
	$('#tr'+key).append(privileges);
	$('div#'+key).html("");
}
function removePrivileges(key)
{
	var privileges = $('#tr'+key).html();
	$('#tr'+key).html("");
	$('#array'+key).html('<a class="btn-12 arrowoff" href="javascript:getPrivileges(\''+key+'\')"></a>');
	$('div#'+key).append(privileges);
}

function check(key)
{
	var n = $("input:checked[id='"+key+"c[]']").length;
	if(n==0)
	{
		$("input[id='"+key+"']").attr("checked",false);
	}
	else
		$("input[id='"+key+"']").attr("checked",true);
}

function abcc()
{
	alert("");
}

</script>